package com.cmxh.mycloudnotes.Service;

import com.cmxh.mycloudnotes.mapper.CategoryMapper;
import com.cmxh.mycloudnotes.pojo.Article;
import com.cmxh.mycloudnotes.pojo.Category;
import com.cmxh.mycloudnotes.util.PageUtil;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CategoryServiceImpl implements CategoryService {

    @Autowired
    private CategoryMapper dao;


    @Override
    public PageInfo<Category> findAll(PageUtil pageUtil) {
        PageHelper.startPage(pageUtil.getPageNum(),pageUtil.getPageSize());
        //设置分页的参数
        Integer id = (Integer) pageUtil.getBenn();
        //第几条数据
        List<Category> list = dao.findAll(id);

        // 记住 只要涉及到分页 后端给前端返回的就不是只有集合
        PageInfo <Category> pageInfo = new PageInfo<>(list);

        return pageInfo;

    }

    @Override
    public int updateZt(int create_user) {
        return dao.updateZt( create_user );
    }

    @Override
    public int save(Category category) {
        return dao.save( category );
    }

    @Override
    public int bianji( Category category) {
        return dao.bianji( category );
    }

}
